package com.okaixz.client.model.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@Data
public class AssistantRequest {

    private HeaderDTO header;
    private ParameterDTO parameter;
    private PayloadDTO payload;

    public AssistantRequest(String appId, String uid, String content) {
//        ParameterDTO.ChatDTO chatDTO=new ParameterDTO.ChatDTO("general",0.5,4,2028);
        ParameterDTO.ChatDTO chatDTO=new ParameterDTO.ChatDTO("general",0.5,4,5000);
        ParameterDTO parameterDTO=new ParameterDTO(chatDTO);
        setParameter(parameterDTO);

        HeaderDTO headerDTO=new HeaderDTO(appId,uid);
        setHeader(headerDTO);

        PayloadDTO.MessageDTO.TextDTO textDTO=new PayloadDTO.MessageDTO.TextDTO("user",content);
        List<PayloadDTO.MessageDTO.TextDTO> list=new ArrayList<>();
        list.add(textDTO);
        PayloadDTO.MessageDTO messageDTO=new PayloadDTO.MessageDTO(list);
        PayloadDTO payloadDTO=new PayloadDTO(messageDTO);
        setPayload(payloadDTO);

    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class HeaderDTO {
        private String app_id;
        private String uid;
    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class ParameterDTO {
        private ChatDTO chat;

        @NoArgsConstructor
        @AllArgsConstructor
        @Data
        public static class ChatDTO {
            private String domain;
            private double temperature;
            private int top_k;
            private int max_tokens;
        }
    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class PayloadDTO {
        private MessageDTO message;

        @NoArgsConstructor
        @AllArgsConstructor
        @Data
        public static class MessageDTO {
            private List<TextDTO> text;

            @NoArgsConstructor
            @AllArgsConstructor
            @Data
            public static class TextDTO {
                private String role;
                private String content;
            }
        }
    }
}
